package org.example.hw.util.mapping;

import org.example.hw.dto.user.ChangePasswordDto;
import org.example.hw.dto.user.EditUserDto;
import org.example.hw.dto.user.RegisterUserDto;
import org.example.hw.model.User;

public class UserMapping {

	public static User mapAdd(RegisterUserDto registerUserDto) {
		User user = new User();

		user.setUsername(registerUserDto.getUsername());
		user.setPassword(registerUserDto.getPassword());
		user.setFirstname(registerUserDto.getFirstname());
		user.setLastname(registerUserDto.getLastname());
		user.setEmail(registerUserDto.getEmail());
		user.setDateOfBirth(registerUserDto.getDateOfBirth());
		user.setActive(true);
		user.setCreatedBy(null);
		user.setModifiedBy(null);

		return user;
	}

	public static void mapEdit(EditUserDto editUserDto, User user) {
		user.setFirstname(editUserDto.getFirstname());
		user.setLastname(editUserDto.getLastname());
		user.setEmail(editUserDto.getEmail());
		user.setDateOfBirth(editUserDto.getDateOfBirth());
		// user.setModifiedBy(user);
	}

	public static void mapEdit(ChangePasswordDto changePasswordDto, User user) {
		user.setPassword(changePasswordDto.getNewPassword());
	}

}
